package com.example.shoppingdemo.nslcommodity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CheckedTextView;

import com.example.shoppingdemo.R;
import com.example.shoppingdemo.nslcommodity.adapter.CheckoutAdapter;
import com.example.shoppingdemo.nslcommodity.adapter.CheckoutModel;

import java.util.ArrayList;
import java.util.List;

public class CheckoutActivity extends AppCompatActivity {
    List<CheckoutModel> models;
    CheckoutAdapter adapter;
    boolean type=true;
    boolean type1=true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_checkout);
        /*Intent intent=getIntent();
        intent.getIntExtra("",-1);
        intent.getIntExtra("",-1);*/
        initView();
    }
    private void initView(){
        RecyclerView checkout=findViewById(R.id.recycler_checkout);
        checkout.setLayoutManager(new LinearLayoutManager(this));
        models=new ArrayList<>();
        CheckoutModel model=new CheckoutModel();
        model.setIcon(R.mipmap.image04);
        model.setMoney("￥59.00");
        model.setNumder("X1");
        model.setTitle("幸福的机会功放开关很快恢复经济急急急");
        model.setSku("幸福光线传媒v和乡村规划");
        models.add(model);
        CheckoutModel model1=new CheckoutModel();
        model1.setIcon(R.mipmap.image04);
        model1.setMoney("￥89.00");
        model1.setNumder("X2");
        model1.setTitle("幸福的机会功放开关很快恢复经济急急急");
        model1.setSku("幸福光线传媒v和乡村规划");
        models.add(model1);
        adapter=new CheckoutAdapter(this);
        adapter.setModelList(models);
        checkout.setAdapter(adapter);
        CheckBox zhifubao=findViewById(R.id.check_checkout_zhifubao);
        CheckBox weixin=findViewById(R.id.check_checkout_weixin);
        zhifubao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!type1){
                    weixin.setChecked(false);
                    type1=true;
                }
                if (type){
                    zhifubao.setChecked(true);
                    type=false;
                }else {
                    zhifubao.setChecked(false);
                    type=true;
                }
            }
        });
        weixin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!type){
                    zhifubao.setChecked(false);
                    type=true;
                }
                if (type1){
                    weixin.setChecked(true);
                    type1=false;
                }else {
                    weixin.setChecked(false);
                    type1=true;
                }

            }
        });
    }
}